package cn.lingnan.controller;

import cn.lingnan.dao.GoodsDao;
import cn.lingnan.entity.goods.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;


@Controller
@RequestMapping("goods")
public class GoodsController {
    @Autowired
    private GoodsDao goodsdao;

    @GetMapping(value="/findAllGoods")
    public String findAllGoods(Model model){
        List<Goods> goodsList = goodsdao.findAllGoods();
        model.addAttribute("goodsList",goodsList);
        return "tgls/goodsManage/goods_list";
    }


    /**
     * 根据商品id查找单个商品
     * @return
     */
    @GetMapping(value="/findGoodsById")
    public Goods findGoodsById(){
        Goods goods= goodsdao.findGoodsById(36);
        return goods;
    }

//    @GetMapping(value="/test3")
//    public void updateTest(){
//        MongoTest mgtest=new MongoTest();
//        mgtest.setId(11);
//        mgtest.setAge(44);
//        mgtest.setName("ceshi2");
//        mtdao.updateTest(mgtest);
//    }

//    @GetMapping(value="/test4")
//    public void deleteTestById(){
//        mtdao.deleteTestById("36");
//    }
}
